<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>个人中心 - 课堂问答</title>
    <!-- Bootstrap -->
<!--<link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">-->
<!--你自己的样式文件 -->
<link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/base.css" />
<link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/fullpage.css" />
<link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/font-awesome.min.css" />
<!-- <link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/login.css" /> -->
<!-- <link href="css/your-style.css" rel="stylesheet">      -->   
<!-- 以下两个插件用于在IE8以及以下版本浏览器支持HTML5元素和媒体查询，如果不需要用可以移除 -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- 如果要使用Bootstrap的js插件，必须先调入jQuery -->
<!--<script src="http://cdn.bootcss.com/jquery/2.0.0/jquery.js"></script>-->
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/jquery.min.js"></script>
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/fullpage.js"></script>
<!-- 包括所有bootstrap的js插件或者可以根据需要使用的js插件调用　-->
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/bootstrap.min.js"></script>
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/base.js"></script>
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/md5.js"></script>
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/vue.js"></script>
<script type="text/javascript" src="/root/mynet/5/quizzhku/1/Public/Js/Chart.min.js"></script>
    
    <link rel="stylesheet" type="text/css" href="/root/mynet/5/quizzhku/1/Public/Css/info.css" />

</head>
<body>
    
    <div class="navbar navbar-inverse" role="navigation">
    <div>
        <div class="navbar-header">
            　<!-- .navbar-toggle样式用于toggle收缩的内容，即nav-collapse collapse样式所在元素 -->
            <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-responsive-collapse">
                <span class="sr-only">Toggle Navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <!-- 确保无论是宽屏还是窄屏，navbar-brand都显示 -->
            <a href="/root/mynet/5/quizzhku/1/index.php" class="navbar-brand">
                <i class="glyphicon glyphicon-book"></i>
                课堂问答系统
            </a>
        </div>
        <!-- 屏幕宽度小于768px时，div.navbar-responsive-collapse容器里的内容都会隐藏，显示icon-bar图标，当点击icon-bar图标时，再展开。屏幕大于768px时，默认显示。 -->
        <div class="collapse navbar-collapse navbar-responsive-collapse">
            <ul class="nav navbar-nav">
                <li><a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classes">我教的班级</a></li>
                <li><a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaCourse/course">我教的课程</a></li>
                <?php if($has_filed > 0): ?><li><a href="javasript:;" id="nav-file">归档管理</a></li><?php endif; ?>
            </ul>
            <ul class="nav navbar-nav pull-right">
                <li class="dropdown">
                    <a href="##" data-toggle="dropdown" class="dropdown-toggle">
                        <?php echo (session('name')); ?><span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-right">
                        <li ><a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaSettings/info"><span class="glyphicon glyphicon-user"></span> 个人设置</a></li>
                        <li ><a href="/root/mynet/5/quizzhku/1/index.php/Home/Auth/logout"><span class="glyphicon glyphicon-log-out"></span> 安全退出</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</div>
<div class="modal fade" id="file-class-modal" role="dialog">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">归档管理</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-3 col-md-offset-9">
                        <select class="form-control choose-course">
                            <option value="all">全部课程</option>
                            <?php if(is_array($courses)): $i = 0; $__LIST__ = $courses;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$cou): $mod = ($i % 2 );++$i;?><option value="<?php echo ($cou["cou_id"]); ?>"><?php echo ($cou["cou_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6 class-panel" id="hidden-panel" value="<?php echo ($cla["cla_id"]); ?>">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h1 class="panel-title"><a><?php echo ($cla["cla_name"]); ?> - <?php echo ($cla["cou_name"]); ?></a></h1>
                                <div class="dropdown pull-right">
                                    <a class="class-edit dropdown-toggle" href="javascript:;" data-toggle="dropdown"><span class="glyphicon glyphicon-menu-hamburger"></span></a>
                                    <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                                        <li><a href="javascript:;" class="menu-class-renew">恢复</a></li>
                                        <li><a href="javascript:;" class="menu-class-delete">删除</a></li>
                                    </ul>
                                </div>
                                <p><small>开始:<?php echo ($cla["cla_start"]); ?> 结束:<?php echo ($cla["cla_end"]); ?></small></p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 删除班级modal -->
<div class="modal fade" id="del-filcla-modal" role="dialog" aria-labelledby="del-class">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title text-danger">删除班级</h4>
            </div>
            <div class="modal-body">
                <p>是否删除班级</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-danger btn-class-del">删除</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function() {
        $("#nav-file").click(function() {
            $("#file-class-modal").modal("toggle");
            $("#file-class-modal .choose-course").val("all");
            postApi("/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/getFiledClass", function(err, data) {
                if (err) {
                    showError(err.message);
                } else {
                    showFiledClass(data.data); // 显示归档班级
                }
            });
        });

        var bgcolors = new Array("default", "info", "primary", "warning", "danger", "success");
        var hidden_panel = $("#hidden-panel"); // 被用来克隆的对象
        hidden_panel.hide();
        function showFiledClass(classes) {
            var dompanel = hidden_panel[0], // 转换成dom对象
                parent = hidden_panel.parent(), // 获取父节点
                panels = parent.find(".class-panel"),
                clone,  // 克隆对象
                clone_jq; // 克隆对象的jquery对象
            panels.slice(1, panels.length).remove(); // 清除班级面板
            for (var i = 0; i < classes.length; i++) {
                clone = dompanel.cloneNode(true);
                clone_jq = $(clone);
                clone_jq.find(".panel-title a").text(classes[i].cla_name + " - " + classes[i].cou_name);
                clone_jq.find(".panel-title a").attr("href", "/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/classStuInfo?cd=" + classes[i].cou_id + "&" + "cad=" + classes[i].cla_id);
                clone_jq.find("p").text("开始:" + classes[i].cla_start + " 结束:" + classes[i].cla_end);
                clone_jq.attr("value", classes[i].cla_id);
                clone_jq.show();
                parent.append(clone_jq);
            }

            $("#file-class-modal .panel").each(function() {
                var num = parseInt($(this).parent().attr("value")) % 6;
                $(this).addClass("panel-"+bgcolors[num]);
            });
            // 监听menu恢复按钮
            $("#file-class-modal .menu-class-renew").click(function() {
                var cla_id = $(this).parents(".class-panel").attr("value");
                postApi("/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/renewClass", {cla_id:cla_id}, function(err, data) {
                    if (err) {
                        showError(err.message);
                    } else {
                        showSuccessReload(data.message);
                    }
                });
            });

            // 判断是否可以删除并弹出modal
            var cur_del_class = {};
            $("#file-class-modal .menu-class-delete").click(function() {
                cur_del_class.id = $(this).parents(".class-panel").attr("value");
                cur_del_class.name = $(this).parents(".panel-heading").find(".panel-title a").text();
                postApi("/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/checkIsDelete", {cla_id:cur_del_class.id}, function(err, data) {
                    if (err) {
                        showError(err.message);
                    } else {
                        $("#del-filcla-modal").modal("toggle");
                        $("#del-filcla-modal").find(".modal-body p").text("是否删除班级 " + cur_del_class.name);
                    }
                });
            });

            // 确认删除
            $("#del-filcla-modal .btn-class-del").click(function() {
                postApi("/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/deleteClass", {cla_id:cur_del_class.id}, function(err, data) {
                    if (err) {
                        showError(err.message);
                    } else {
                        $("#del-filcla-modal").modal("toggle");
                        showSuccessReload(data.message);
                    }
                });
            });
        }

        // 监听下拉框选择事件
        $("#file-class-modal .choose-course").change(function() {
            var cd = "";
            if ($(this).val() != "all")
                cd = $(this).val();
            postApi("/root/mynet/5/quizzhku/1/index.php/Home/TeaClass/getFiledClass", (cd?{cd:cd}:{}), function(err, data) {
                if (err) {
                    showError(err.message);
                } else {
                    showFiledClass(data.data); // 显示归档班级
                }
            });
        });
    });
</script>  

    
    <div class="container" id="container">
        <div class="row">
            <div class="col-md-offset-2 col-md-8 margin-bottom-10">
                <div class="alert alert-danger hidden" role="alert"></div>
                <nav class="nav nav-pills">
                    <li class="active"><a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaSettings/info">基本资料</a></li>
                    <li><a href="/root/mynet/5/quizzhku/1/index.php/Home/TeaSettings/change_pwd">密码管理</a></li>
                </nav>
            </div>
        </div>
        <div class="row">
            <div class="col-md-offset-2 col-md-8">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-4">
                            <ul class="list-inline">
                                <li><b>邮箱:</b></li>
                                <li><?php echo ($info["tea_email"]); ?></li>
                            </ul>
                            </div>
                        </div>
                        <div class="row" id="name">
                            <div class="col-md-11">
                                <ul class="list-inline">
                                    <li><label>姓名:</label></li>
                                    <li><input class="form-control" type="text" value="<?php echo ($info["tea_name"]); ?>" required
                                        placeholder="请输入姓名">
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <div class="row" id="sex">
                            <div class="col-md-11">
                                <ul class="list-inline">
                                    <li><label>性别:</label></li>
                                    <label class="radio-inline">
                                        <input type="radio" value="男" name="sex"<?php if($info["sex"] == '男'): ?>checked="checked"<?php endif; ?>>男性
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" value="女" name="sex" <?php if($info["sex"] == '女'): ?>checked="checked"<?php endif; ?>>女性
                                    </label>
                                </ul>
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-11">
                                <ul class="list-inline">
                                    <li><label>机构:</label></li>
                                    <li><?php echo ($info["col_name"]); ?></li>
                                </ul>
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-11">
                                <ul class="list-inline">
                                    <li><label>身份:</label></li>
                                    <li><?php echo ($info["state"]); ?></li>
                                </ul>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-11">
                                <ul class="list-inline">
                                    <?php if($info["state"] == '教师'): ?><li><label>教工号:</label></li>
                                        <?php else: ?>
                                        <li><label>学号:</label></li><?php endif; ?>
                                    <li><?php echo ($info["tea_number"]); ?></li>
                                </ul>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-11">
                                <button id="modified" class="btn btn-primary">修改</button>
                                <label style="display:none; color:red" id="message"></label>
                            </div>
                            <input type="hidden" id="url" value="/root/mynet/5/quizzhku/1/index.php/Home"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        $(function(){
            var name = $("#name input");
            var sex = $("#sex input:checked");

            $("#modified").click(function(e){        
                $(this).blur();
                var name_input = name.val();
                var sex_input = $("#sex input:checked").val();
                if (name_input !== "") {
                    postApi("/root/mynet/5/quizzhku/1/index.php/Home/TeaSettings/Update_tea_info", {tea_name:name_input,sex:sex_input},
                        function(err, data) {
                            if (err) {
                                showError(err.message);
                            } else {
                                $("#message").html("修改成功");
                                $("#message").fadeIn("fast");// 弹出;
                                $("#message").fadeOut(2000); //变淡消失
                                //setTimeout("$('#message').hide()",3000);
                                setTimeout(" window.location.href=$('#url').val()+'/TeaSettings/info'",1000);
                            }
                        });
                }

                if (name_input === "") {
                    showError("姓名不能为空");
                    name.focus();
                }
            });
        });
    </script>

</body>